{% extends "base.html" %}
{% from "dashboards/includes/macros.html" import print_readout, overview_section, product_choice_list, print_subscription_menu with context %}
{% from "dashboards/includes/macros.html" import localization_sidebar_nav %}
{% set title = _('[{locale}][{product}] Localization Dashboard')|fe(locale=current_locale, product=pgettext('DB: products.Product.title', product.title) if product else _('All Products')) %}
{% set scripts = ('wiki', 'jqueryui', 'wiki.dashboard') %}
{% set styles = ('kbdashboards', 'jqueryui') %}
{% set crumbs = [(None, title)] %}
{% set classes = 'localization-dashboard' %}
{# TODO: Move required dashboard scripts out of wiki.js into their own or refactor up? #}

{% block content %}
  <div class="grid_9">
    <article id="localize" class="dashboards">
      <h1>{{ title }}</h1>
      <h2>{{ _('Locale:') }} {{ current_locale_name }}</h2>

      {% if user.is_anonymous() %}
        <section id="get-involved-box">
          <a class="button" href="{{ url('landings.get_involved_l10n') }}">
            {{ _('Volunteer for Mozilla Support') }}
          </a>
        </section>
      {% endif %}

      {% if announcements %}
        <ul class="announcements">
          {% for a in announcements %}
            <li>
              {{ a.content|wiki_to_html }}
              <p>
                {{ datetimeformat(a.show_after, 'date') }}
                {% if user_can_announce %}
                  <a href="{{ url('announcements.delete', a.id) }}" class="delete">
                    {{ _('Delete') }}
                  </a>
                {% endif %}
              </p>
            </li>
          {% endfor %}
        </ul>
      {% endif %}

      {% if user_can_announce %}
        <div id="create-announcement">
          <button class="btn">
            <img src="{{ STATIC_URL }}sumo/img/blank.png" />
            {{ _('Create announcement') }}
          </button>
          <span class="success">{{ _('Created successfully') }}</span>
          <div class="kbox" data-target="#create-announcement > .btn" data-position="none" data-close-on-out-click="true">
            <form action="{{ url('announcements.create_for_locale') }}" method="POST">
              {% csrf_token %}
              <ul>
                {{ announce_form.as_ul() }}
                <li>
                  <button type="submit" class="btn btn-submit" value="Submit">
                    {{ _('Create') }}
                  </button>
                  <img src="{{ STATIC_URL }}sumo/img/wait-trans.gif" class="spinner" />
                </li>
              </ul>
            </form>
          </div>
        </div>
      {% endif %}

      {{ product_choice_list(products, product, url('dashboards.localization')) }}

      {% if not user.is_anonymous() %}
        {{ print_subscription_menu(default_locale_name,
                                   current_locale_name,
                                   on_default_locale,
                                   is_watching_default_locale,
                                   is_watching_other_locale,
                                   is_watching_default_approved,
                                   is_watching_other_approved,
                                   settings.WIKI_DEFAULT_LANGUAGE,
                                   product=product) }}
      {% endif %}

      {{ overview_section(readouts, ((overview_rows['top-100'], True),
                                     (overview_rows['top-50'], True),
                                     (overview_rows['top-20'], True),
                                     (overview_rows['all'], True),
                                     (overview_rows['templates'], True))) }}

      <div id="stats-tabs" data-ui-type="tabbed-view">
        <ul class="cf" data-tab-role="tabs">
          <li>{{ _('Localization') }}</li>
          <li>{{ _('Review') }}</li>
        </ul>
        <div data-tab-role="panels">
          <div>
            {{ print_readout(readouts['most-visited-translations'], max_rows=20, product=product) }}
          </div>
          <div>
            {{ print_readout(readouts['unreviewed'], max_rows=10, product=product) }}
          </div>
        </div>
      </div>

      {{ print_readout(readouts['template-translations'], max_rows=10, product=product) }}
    </article>
  </div>
{% endblock %}

{% block side_top %}
  {{ localization_sidebar_nav(current_locale, 'dashboard') }}
{% endblock %}
